package hu.plusone.eregister.service.dao;

import hu.plusone.eregister.dao.NurseryDao;
import hu.plusone.eregister.model.Nursery;
import hu.plusone.eregister.service.NurseryService;
import java.util.Collection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Scope("singleton")
public class NurseryServiceImpl implements NurseryService {

    @Autowired
    private NurseryDao dao;

    @Override
    public Nursery get(Long id) {
        return dao.findOne(id);
    }

    @Override
    public Iterable<Nursery> getAll() {
        return dao.findAll();
    }

    @Override
    @Transactional
    public void save(Nursery model) {
        dao.save(model);
    }

    @Override
    @Transactional
    public void delete(Long id) {
        dao.delete(id);
    }

    @Override
    public Collection<Nursery> findAllByChildId(long childId) {
        return dao.findAllByChildId(childId);
    }
    
}
